package com.lovo.pay.service.impl;

import com.lovo.common.bean.OrderBean;
import com.lovo.common.util.RedisUtil;
import com.lovo.pay.service.ICommodityService;
import com.lovo.pay.service.IOrderService;
import com.lovo.pay.service.IPayService;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@GlobalTransactional(rollbackFor = Throwable.class)
public class PayServiceImpl implements IPayService {
    @Resource
    private ICommodityService commodityService;
    @Resource
    private IOrderService orderService;
    @Resource
    private RedisUtil redisUtil;
    @Override
    public void update(String orderId) {
        OrderBean orderBean = (OrderBean) redisUtil.hget("seckillOrder",orderId);
        commodityService.updateStock(orderBean.getCommId());
        orderService.updateOrderStatus(orderId);
    }
}
